//
//  DCHttpRequest.m
//  Demo
//
//  Created by Kyle on 2022/12/31.
//

#import "DCHttpRequest.h"
#import "DCHttpDocument.h"
@implementation DCHttpRequest

/**
 TODO:统一方法 拼接URL
 
 @param url 接口最后路径
 @return 处理完成接口
 */
+ (NSString *)assemblyURLByBaseRequest:(NSString *)url {
    url = [NSString stringWithFormat:@"%@%@%@",API_address,@"app-loanmarket-api/",url];
    return url;
}

+ (NSURLSessionDataTask *)DCgetSmsWithPhoneNum:(NSString *)phoneNum registerType:(NSString *)type completeBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:getSms];
    NSDictionary *par =  @{ @"phone":phoneNum,
                            @"type":type,
                            @"voiceCode":@"false",
    };
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
    
}

+ (NSURLSessionDataTask *)DCLoginWithPhoneNum:(NSString *)phone vcode:(NSString *)vcode  completeBlock:(NSmartCompleteBlock)completeBlock {
    NSString *loginUrl = [self assemblyURLByBaseRequest:loginRegiset];
    NSDictionary *par = @{ @"loginName":phone,
                           //      @"loginType":@"SMS(短信登录),PWD(密码登录)",
                           //      @"merchantNo":@"cashloan",
                           @"vcode":vcode,
                           //      @"pwd":@""
    };
    return [[DCHttpManager shareInfo] postMessageWithUrl:loginUrl parameters:par complete:completeBlock];
}


//用户基本信息
+ (NSURLSessionDataTask *)DCBaseUserInfoCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:userBaseInfo];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

//用户投诉
+ (NSURLSessionDataTask *)DCUserComplaintWithMessage:(NSString *)message completeBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:userComplaint];
    NSDictionary *par = @{ @"content":message,
                           @"title":@"native_feedback"
    };
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}
//获取银行卡列表
+ (NSURLSessionDataTask *)DCBankCardListCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:bankCardList];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

+ (NSURLSessionDataTask *)DCLogoutCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *logoutUrl = [self assemblyURLByBaseRequest:userLogout];
    return [[DCHttpManager shareInfo] postMessageWithUrl:logoutUrl parameters:@{} complete:completeBlock];
    
}

//修改银行卡
+ (NSURLSessionDataTask *)DCmodifyBankcard:(NSString *)bandCode step:(NSString *)step vcode:(NSString *)vcode CompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:modifyBankcard];
    NSDictionary *par = @{@"data":bandCode,@"step":step,@"vcode":vcode};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

//银行列表
+ (NSURLSessionDataTask *)DCBankListCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:bankList];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

//获取客服信息
+ (NSURLSessionDataTask *)DCCustomerServiceInfoCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:customerServiceInfo];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}
//检查用户扩展信息是否过期（true为过期，false为未过期）
+ (NSURLSessionDataTask *)DCAuthCheckExtExpiredCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:authCheckExtExpired];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}
//获取用户授权数据
+ (NSURLSessionDataTask *)DCAuthCheckCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:authCheck];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

+ (NSURLSessionDataTask *)DCAuthUploadLiveImage:(NSData*)imageData CompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:uploadLive];
    NSDictionary *par = @{@"photo":imageData};
    return [[DCHttpManager shareInfo] postMessageContentImageWithUrl:url parameters:par complete:completeBlock];
}

///获取下一步该填写信息的step,如果信息都填写完毕，返回100，其他返回未填写的step
+ (NSURLSessionDataTask *)DCAuthNextStepCompleteBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:nextStep];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

//保存用户信息(词汇映射)
+ (NSURLSessionDataTask *)DCAuthSaveInfo2:(NSString *)step data:(NSString *)data completeBlock:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:saveUserInfo2];
    NSDictionary *par = @{@"step":step,@"data":data};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

//字典列表
+ (NSURLSessionDataTask *)DCDictListWithType:(NSString *)type complate:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:dictList];
    url = [NSString stringWithFormat:@"%@?type=%@",url,type];
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

//上传证件正面
+ (NSURLSessionDataTask *)DCOSSUploadPositiveImage:(NSData*)imageData complate:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:ossUploadPositive];
    NSDictionary *par = @{@"photo":imageData};
    return [[DCHttpManager shareInfo] postMessageContentImageWithUrl:url parameters:par complete:completeBlock];
}

/// 借款列表
+ (NSURLSessionDataTask *)DCOrderListType:(NSString *)type pageNum:(NSInteger)pageNum complate:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:orderList];
    NSDictionary *par = @{@"type":type,
                          @"pageNum":@(pageNum),
                          @"pageSize":@"10" };
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

// 订单详情
+ (NSURLSessionDataTask *)DCOrderDetialWithOrderNo:(NSString *)orderNo complate:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:orderDetail];
    url = [NSString stringWithFormat:@"%@?orderNo=%@",url,orderNo];
    //    NSDictionary *par = @{@"orderNo":orderNo};
    NSDictionary *par = @{};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}

/// 展期借款周期计算信息
/// - Parameters:
///   - orderNo: 订单编号 ,
///   - termUnit: 周期单位 1：天2：月，可为空
///   - delayTerm: 延期周期，可为空 ,
///   - completeBlock: 完成回调
+ (NSURLSessionDataTask *)DCCalculateDelayWithorderNo:(NSString *)orderNo TermUnit:(NSString *)termUnit delayTerm:(NSString *)delayTerm complate:(NSmartCompleteBlock)completeBlock {
    NSString *url = [self assemblyURLByBaseRequest:calculateDelay];
    NSDictionary *par = @{@"orderNo":orderNo,@"termUnit":termUnit,@"delayTerm":delayTerm};
    return [[DCHttpManager shareInfo] postMessageWithUrl:url parameters:par complete:completeBlock];
}
@end
